$(document).ready(function ()
{
	/** Verification longueur mot de passe **/
	$("#password").keyup(function ()
	{
		var long_password = $(this).val().length;
		var password = $(this).val();
		var conf_password = $("#conf_password").val();

        if (password == "")
        {
           	$("#password").css({
           		color: "#0088ff",
           		border: "2px solid #0088ff"
           	});
           	$("#password").removeClass("incorrect");
        }
        else if (long_password < 6)
        {
           	$("#password").css({
           		color: "#fff",
           		border: "2px solid #c93030"
           	});
           	$("#password").removeClass("correct");
           	$("#password").addClass("incorrect");
           	$("#conf_password").attr("disabled", "disabled");
        }
        else
        {
           	$("#password").css({
           		color: "#fff",
           		border: "2px solid #0088ff"
           	});
           	$("#password").addClass("correct");
           	$("#conf_password").removeAttr("disabled");
        }
	})

	/** Vérification coordonnance des mots de passe **/
	$("#conf_password").keyup(function ()
	{
		var conf_password = $(this).val();
		var password = $("#password").val();

		if (conf_password == password)
		{
			$("#conf_password").css({
           		color: "#fff",
           		border: "2px solid #0088ff"
           	});
			$("#conf_password").removeClass("incorrect");
			$("#conf_password").addClass("correct");
		}
		else if (conf_password == "")
		{
			$("#conf_password").css({
           		color: "#0088ff",
           		border: "2px solid #0088ff"
           	});
			$("#conf_password").removeClass("incorrect");
		}
		else
		{
			$("#conf_password").css({
           		color: "#fff",
           		border: "2px solid #c93030"
           	});
			$("#conf_password").removeClass("correct");
			$("#conf_password").addClass("incorrect");
		}
	})

	/** suppression des style au changement de champ **/
	$("#password").blur(function ()
	{
		$("#password").css({
       		color: "#0088ff",
       		border: "2px solid #63b6ff"
       	});
		$("#password").removeClass("correct");
		$("#password").removeClass("incorrect");
	})

	$("#conf_password").blur(function ()
	{
		$("#conf_password").css({
       		color: "#0088ff",
       		border: "2px solid #63b6ff"
       	});
		$("#conf_password").removeClass("correct");
        $("#conf_password").removeClass("incorrect");
	})
		
	/** changement des style au focus du champ **/
	$("#password").focus(function ()
	{
		$("#password").css("border", "2px solid #0088ff");
		$("#password").removeClass("correct");
		$("#password").removeClass("incorrect");
	})
		
	$("#conf_password").focus(function ()
	{
		$("#conf_password").css("border", "2px solid #0088ff");
		$("#conf_password").removeClass("correct");
        $("#conf_password").removeClass("incorrect");
	})
});